package fr.rhoc.android;

import fr.rhoc.android.R;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

public class UpdateParameters extends Activity {

	public static final String PREFS_NAME = "RHOCPrefs";
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		setContentView(R.layout.parameters);

		final EditText txtRhocId = (EditText) findViewById(R.id.txtRhocId);
		
		
		SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
		txtRhocId.setText(settings.getString("rhocId", ""));
		
		txtRhocId.addTextChangedListener(new TextWatcher() {

			public void onTextChanged(CharSequence arg0, int arg1, int arg2,
					int arg3) {
			}

			public void beforeTextChanged(CharSequence arg0, int arg1,
					int arg2, int arg3) {
			}

			public void afterTextChanged(Editable arg0) {
				SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
				SharedPreferences.Editor editor = settings.edit();
				editor.putString("rhocId", arg0.toString());
				// Commit the edits!
				editor.commit();
			}
		});

	}

}